<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>后台登录-X-admin1.1</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
    <link rel="stylesheet" href="__PUBLIC__/admin/css/font.css">
    <link rel="stylesheet" href="__PUBLIC__/admin/css/xadmin.css">
    <link rel="stylesheet" href="https://cdn.bootcss.com/Swiper/3.4.2/css/swiper.min.css">
    <script type="text/javascript" src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
    <script type="text/javascript" src="https://cdn.bootcss.com/Swiper/3.4.2/js/swiper.jquery.min.js"></script>
    <script src="__PUBLIC__/admin/lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="__PUBLIC__/admin/js/xadmin.js"></script>

</head>
<body>
    <!-- 中部开始 -->
    <div class="wrapper">
        <!-- 右侧主体开始 -->
        <div class="page-content">
          <div class="content">
            <xblock>
                <button class="layui-btn" onclick="member_add('添加项目','{:U('admin/user/addlw',['uid'=>$uid])}','600','500')"><i class="layui-icon">&#xe608;</i>添加</button>
            </xblock>
            <table class="layui-table">
                <thead>
                    <tr>
                        <th>ID</th>
                        <th>用户名</th>
                        <th>礼卷名</th>
                        <th>标签名</th>
                        <th style="width: 80px;">发布时间</th>
                        <th style="width: 80px;">使用时间</th>
                        <th style="text-align: center;width: 90px;">状态<font color="red" style="font-size: 8px;"><br>(点击更改状态)</font></th>
                        <th>操作</th>
                    </tr>
                </thead>
                <tbody>
                <?php foreach ($lps as $v) { ?>
                    <tr>
                        <td>{$v.id}</td>
                        <td><?php echo reuid_name($v['uid']) ?></td>
                        <td>{$v.title}</td>
                        <td>{$v.xioc}</td>
                        <td><?php echo date('Y-m-d H:i:s',$v['time']) ?></td>
                        <td><?php if ($v['sytime'] ==0) { ?>
                                未使用
                            <?php }else { ?>
                                <?php echo date('Y-m-d H:i:s',$v['sytime']) ?> 
                            <?php } ?>
                        </td>
                        <td>
                            <if condition="$v['is_sy'] eq 1">
                                <a onclick="no_ly(this,'{$v.id}')" title="点击下线" style="background: green;padding: 5px 0px;font-size: 8px;cursor:pointer">已发放</a>
                            <else />
                                <a onclick="yes_ly(this,'{$v.id}')" title="点击上线" style="background: #aca9a9;padding: 5px 0px;font-size: 8px;cursor:pointer">未发放</a>
                            </if>
                        </td>
                        <td class="td-manage">

                            <a title="删除" href="javascript:;" onclick="member_del(this,'{$v.id}')" style="text-decoration:none"><i class="layui-icon">&#xe640;</i></a>

                        </td>
                    </tr>
                <?php } ?>
                </tbody>
            </table>
          </div>
        </div>
        <!-- 右侧主体结束 -->
    </div>
    <!-- 中部结束 -->
        <script>
            layui.use(['form','layer'], function(){
                $ = layui.jquery;
              var form = layui.form()
              ,layer = layui.layer;
              
            });

         /*添加*/
        function member_add(title,url,w,h){
            x_admin_show(title,url,w,h);
        }

        /*zt rz*/
        function yes_ly(obj,id){
            layer.confirm('确认发放吗？',function(index){
                //发异步删除数据
                id = id;
                $.ajax({
                    url: "{:U('admin/user/yesly')}",//请求地址
                    type: "post",//请求方式
                    dataType: "json",//返回数据类型
                    data: {id:id},//发送的参数
                    })
                    .done(function(response) {
                          if(response.error==1){
                            layer.msg(response.info ,{icon:6});
                            location.reload();
                          }else{
                            layer.msg(response.info ,{icon:5});
                          }
                      })
                    .fail(function() {
                        alert("ajxs交互失败");
                    })  
                return false;
            });
        }
        function no_ly(obj,id){
            layer.confirm('确认取消发放吗？',function(index){
                //发异步删除数据
                id = id;
                $.ajax({
                    url: "{:U('admin/user/noly')}",//请求地址
                    type: "post",//请求方式
                    dataType: "json",//返回数据类型
                    data: {id:id},//发送的参数
                    })
                    .done(function(response) {
                          if(response.error==1){
                            layer.msg(response.info ,{icon:6});
                            location.reload();
                          }else{
                            layer.msg(response.info ,{icon:5});
                          }
                      })
                    .fail(function() {
                        alert("ajxs交互失败");
                    })  
                return false;
            });
        }

        /*删除*/
        function member_del(obj,id){
            layer.confirm('确认要删除吗？',function(index){
                //发异步删除数据
                id = id;
                $.ajax({
                    url: "{:U('admin/user/dellw')}",//请求地址
                    type: "post",//请求方式
                    dataType: "json",//返回数据类型
                    data: {id:id},//发送的参数
                    })
                    .done(function(response) {
                          if(response.error==1){
                            layer.msg(response.info ,{icon:6});
                            $(obj).parents("tr").remove();
                          }else{
                            layer.msg(response.info ,{icon:5});
                          }
                      })
                    .fail(function() {
                        alert("ajxs交互失败");
                    })  
                return false;
            });
        }

        </script>
</body>
</html>